package com.example.sockjsclient;

import com.example.sockjsclient.sockjs.SockJSClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SockJsClientApplication implements CommandLineRunner {

    @Autowired
    private SockJSClientService sockJSClientService;

    @Value("${sockjs.server.url}")
    private String serverUrl;

    public static void main(String[] args) {
        SpringApplication.run(SockJsClientApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
//        String destination = "/topic/notifications";
//        sockJSClientService.connectAndSubscribe(url, destination,"apiKey");
        sockJSClientService.connectAndSubscribe(serverUrl, "");
    }
}
